﻿<UserControl x:Class="MergeTool.UI.Views.SetConfigBranchesView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:mui="http://firstfloorsoftware.com/ModernUI"
             xmlns:core="clr-namespace:System;assembly=mscorlib"
             xmlns:mergeOptionsExns="clr-namespace:Microsoft.TeamFoundation.VersionControl.Common;assembly=Microsoft.TeamFoundation.VersionControl.Common"
             xmlns:helpers="clr-namespace:MergeTool.UI.Helpers"
             mc:Ignorable="d" 
             d:DesignHeight="600" d:DesignWidth="600">

    <Grid>
        <Grid.Resources>
            <ObjectDataProvider x:Key="MergeOptionEnum" MethodName="GetValues" ObjectType="{x:Type core:Enum}">
                <ObjectDataProvider.MethodParameters>
                    <x:Type Type="mergeOptionsExns:MergeOptionsEx"/>
                </ObjectDataProvider.MethodParameters>
            </ObjectDataProvider>
            <helpers:IgnoreNewItemPlaceHolderConverter x:Key="IgnoreNewItemPlaceHolderConverter"/>
            
            <Style TargetType="{x:Type mui:ModernButton}" BasedOn="{StaticResource {x:Type mui:ModernButton}}">
                <Setter Property="EllipseDiameter" Value="26"/>
                <Setter Property="IconWidth" Value="14"/>
                <Setter Property="IconHeight" Value="14"/>
            </Style>
        </Grid.Resources>
        <ScrollViewer>
            <StackPanel HorizontalAlignment="Left">
                    <GroupBox HorizontalAlignment="Left">
                        <GroupBox.Header>
                            <Label Margin="10">Merge approaches</Label>
                        </GroupBox.Header>
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"></RowDefinition>
                                <RowDefinition Height="Auto"></RowDefinition>
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"></ColumnDefinition>
                            </Grid.ColumnDefinitions>

                            <StackPanel HorizontalAlignment="Right" Orientation="Horizontal" Grid.Row="0" Grid.Column="0">
                                <TextBox Name="ApproachFormTextBox" Text="{Binding Path=SelectedMergeApproach.Name, UpdateSourceTrigger=Explicit}" MinWidth="150" Margin="0,0,20,0" />
                                <Grid HorizontalAlignment="Left">
                                    <ItemsControl  ItemsSource="{Binding Path=MergeApproaches, Mode=OneWay}" Height="0" Margin="20,0">
                                        <ItemsControl.ItemTemplate>
                                            <DataTemplate>
                                                <TextBlock Text="{Binding Path=Name}"/>
                                            </DataTemplate>
                                        </ItemsControl.ItemTemplate>
                                    </ItemsControl>
                                    <ComboBox  ItemsSource="{Binding Path=MergeApproaches, Mode=OneWay}" VerticalAlignment="Center">
                                        <ComboBox.ItemTemplate>
                                            <DataTemplate>
                                                <TextBlock Text="{Binding Path=Name}"/>
                                            </DataTemplate>
                                        </ComboBox.ItemTemplate>
                                    </ComboBox>
                                </Grid>
                            </StackPanel>
                            <StackPanel Grid.Row="1" Grid.Column="0" Orientation="Horizontal" HorizontalAlignment="Left">
                                <StackPanel.Resources>
                                    <PathGeometry x:Key="AddIcon">F1 M 35,19L 41,19L 41,35L 57,35L 57,41L 41,41L 41,57L 35,57L 35,41L 19,41L 19,35L 35,35L 35,19 Z</PathGeometry>
                                    <PathGeometry x:Key="RemoveIcon">F1 M 26.9166,22.1667L 37.9999,33.25L 49.0832,22.1668L 53.8332,26.9168L 42.7499,38L 53.8332,49.0834L 49.0833,53.8334L 37.9999,42.75L 26.9166,53.8334L 22.1666,49.0833L 33.25,38L 22.1667,26.9167L 26.9166,22.1667 Z</PathGeometry>
                                    <PathGeometry x:Key="EditIcon">F1 M 53.2929,21.2929L 54.7071,22.7071C 56.4645,24.4645 56.4645,27.3137 54.7071,29.0711L 52.2323,31.5459L 44.4541,23.7677L 46.9289,21.2929C 48.6863,19.5355 51.5355,19.5355 53.2929,21.2929 Z M 31.7262,52.052L 23.948,44.2738L 43.0399,25.182L 50.818,32.9601L 31.7262,52.052 Z M 23.2409,47.1023L 28.8977,52.7591L 21.0463,54.9537L 23.2409,47.1023 Z</PathGeometry>
                                </StackPanel.Resources>
                                <mui:ModernButton IconData="{StaticResource AddIcon}" Command="{Binding AddApproachCommand, Mode=OneWay}" Margin="10,8" />
                                <mui:ModernButton IconData="{StaticResource EditIcon}" Command="{Binding EditApproachCommand, Mode=OneWay}" Margin="10,8" />
                                <mui:ModernButton IconData="{StaticResource RemoveIcon}" Command="{Binding RemoveApproachCommand, Mode=OneWay}" Margin="10,8" />
                            </StackPanel>
                        </Grid>
                    </GroupBox>

                <GroupBox HorizontalAlignment="Left">
                    <GroupBox.Header>
                        <Label Margin="10">Branches</Label>
                    </GroupBox.Header>
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"></RowDefinition>
                            <RowDefinition Height="Auto"></RowDefinition>
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                        </Grid.ColumnDefinitions>

                        <DataGrid GridLinesVisibility="All" ItemsSource="{Binding Path=BranchesObservable, Mode=TwoWay}" SelectedItem="{Binding Path=SelectedBranchPair, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay, Converter={StaticResource IgnoreNewItemPlaceHolderConverter}}" SelectionMode="Single" AutoGenerateColumns="False" >
                            <DataGrid.Columns>
                                <mui:DataGridTextColumn Header="Order" Binding="{Binding Order, Mode=TwoWay}"/>
                                <mui:DataGridTextColumn Header="From" Binding="{Binding BranchNameFrom, Mode=TwoWay}" />
                                <mui:DataGridTextColumn Header="To" Binding="{Binding BranchNameTo, Mode=TwoWay}" />
                                <mui:DataGridComboBoxColumn Header="Merge Option" SelectedItemBinding="{Binding MergeOption, Mode=TwoWay}" ItemsSource="{Binding Source={StaticResource MergeOptionEnum}}" />
                                <mui:DataGridTextColumn Header="Skip changesets" Binding="{Binding ChangesetIdToStartFrom,Mode=TwoWay}" />
                                <mui:DataGridTextColumn Header="Comment Pattern" Binding="{Binding CheckinCommentPattern,Mode=TwoWay}" />
                            </DataGrid.Columns>
                        </DataGrid>

                        <StackPanel Grid.Row="1" Grid.Column="0" Orientation="Horizontal" HorizontalAlignment="Left">
                            <StackPanel.Resources>
                                <PathGeometry x:Key="RemoveIcon">F1 M 26.9166,22.1667L 37.9999,33.25L 49.0832,22.1668L 53.8332,26.9168L 42.7499,38L 53.8332,49.0834L 49.0833,53.8334L 37.9999,42.75L 26.9166,53.8334L 22.1666,49.0833L 33.25,38L 22.1667,26.9167L 26.9166,22.1667 Z</PathGeometry>
                                <PathGeometry x:Key="MoveUpIcon">F1 M 42,19.0002L 34,19.0002L 34,43.7502L 24,33.7502L 24,44.2502L 38,58.2502L 52,44.2502L 52,33.7502L 42,43.7502L 42,19.0002 Z</PathGeometry>
                                <PathGeometry x:Key="MoveDownIcon">F1 M 42,19.0002L 34,19.0002L 34,43.7502L 24,33.7502L 24,44.2502L 38,58.2502L 52,44.2502L 52,33.7502L 42,43.7502L 42,19.0002 Z</PathGeometry>
                            </StackPanel.Resources>
                            <mui:ModernButton IconData="{StaticResource RemoveIcon}" Command="{Binding RemoveBranchCommand, Mode=OneWay}" Margin="10,8" />
                            <mui:ModernButton IconData="{StaticResource MoveUpIcon}" Command="{Binding MoveBranchUpCommand, Mode=OneWay}" Margin="10,8" RenderTransformOrigin="0.5,0.5" >
                                <mui:ModernButton.RenderTransform>
                                    <TransformGroup>
                                        <ScaleTransform/>
                                        <SkewTransform/>
                                        <RotateTransform Angle="-180"/>
                                        <TranslateTransform/>
                                    </TransformGroup>
                                </mui:ModernButton.RenderTransform>
                            </mui:ModernButton>
                            <mui:ModernButton IconData="{StaticResource MoveDownIcon}" Command="{Binding MoveBranchDownCommand, Mode=OneWay}" Margin="10,8" />
                        </StackPanel>
                    </Grid>
                </GroupBox>
            </StackPanel>
        </ScrollViewer>
    </Grid>
</UserControl>